import "antd/es/button/style";
import _Button from "antd/es/button";
import "antd/es/breadcrumb/style";
import _Breadcrumb from "antd/es/breadcrumb";
import React from 'react';
import "./index.less";
import { Link } from 'react-router-dom';
import { withNativeProps } from "../utils/native-props";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var Page = function Page(props) {
  var children = props.children,
    breadcrumb = props.breadcrumb,
    _props$breadcrumbPadd = props.breadcrumbPadding,
    breadcrumbPadding = _props$breadcrumbPadd === void 0 ? 20 : _props$breadcrumbPadd,
    pageInnerStyle = props.pageInnerStyle,
    operations = props.operations,
    operationsStyle = props.operationsStyle,
    backButton = props.backButton,
    extra = props.extra;
  return withNativeProps(props, /*#__PURE__*/_jsxs("div", {
    className: "pd-page",
    style: {
      // 没有面包屑的情况只能为 0，有面包屑的情况会取 breadcrumbPadding，默认为 20
      paddingTop: breadcrumb ? 0 : breadcrumbPadding,
      paddingBottom: operations ? 84 : 20
    },
    children: [breadcrumb && /*#__PURE__*/_jsxs("div", {
      className: "pd-page-header",
      children: [/*#__PURE__*/_jsx(_Breadcrumb, {
        style: {
          padding: "".concat(breadcrumbPadding, "px 0")
        },
        children: breadcrumb.map(function (item, index) {
          var isString = typeof item === 'string';
          if (isString) {
            return /*#__PURE__*/_jsx(_Breadcrumb.Item, {
              children: item
            }, index);
          }
          return /*#__PURE__*/_jsx(_Breadcrumb.Item, {
            children: item.path && index !== (breadcrumb === null || breadcrumb === void 0 ? void 0 : breadcrumb.length) - 1 ? /*#__PURE__*/_jsx(Link, {
              to: item.path,
              children: item.name
            }) : item.name
          }, index);
        })
      }), /*#__PURE__*/_jsxs("div", {
        className: "pd-page-header-operations",
        children: [extra && /*#__PURE__*/_jsx("div", {
          className: "pd-page-header-operations-more",
          children: extra
        }), backButton && /*#__PURE__*/_jsx(_Button, {
          className: "pd-page-back-button",
          onClick: function onClick() {
            window.history.go(-1);
          },
          children: "\u8FD4\u56DE"
        })]
      })]
    }), /*#__PURE__*/_jsx("div", {
      className: "pd-page-inner",
      style: pageInnerStyle,
      children: children
    }), operations && /*#__PURE__*/_jsx("div", {
      className: "pd-page-operations",
      style: operationsStyle,
      children: operations
    })]
  }));
};
export default Page;